package com.hpu.service;

import java.util.ArrayList;
import java.util.List;

import com.hpu.dao.MenuCommentDao;
import com.hpu.dao.MenuDao;
import com.hpu.dao.OrderDao;
import com.hpu.entity.Menu;
import com.hpu.entity.Menu_Comment;
import com.hpu.entity.Order;

public class MenuCommentService {

	MenuDao menuDao = new MenuDao();
	MenuCommentDao menuCommentDao = new MenuCommentDao();
	OrderDao orderDao = new OrderDao();
	
	public List<Menu> findAllMenu(){
		List<Menu> menuList = menuDao.findAllMenus();
		List<Menu_Comment> commentList = menuCommentDao.findAllComments();
		
		List<Menu> menus = new ArrayList<Menu>();
		
		for (Menu menu : menuList) {
			List<Menu_Comment> comments = new ArrayList<Menu_Comment>();
			for (Menu_Comment menu_Comment : commentList) {
				if (menu.getId() == menu_Comment.getMenu_id()) {
					comments.add(menu_Comment);
				}
			}
			menu.setCommentList(comments);
			menus.add(menu);
		}
		
		return menus;
	}
	public List<Order> findAllOrders(){
		return orderDao.findAllOrders();
	}
	
	
	
}
